<html>
  <head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<!-- fragment for displaying the page -->
<script type="text/javascript"><!--
    var chart;
    
      google.load("visualization", "1", {packages:['imagelinechart']});
      google.setOnLoadCallback(drawChart);
      function drawChart() {   
        chart = new google.visualization.ImageLineChart(document.getElementById('chart_div'));
        getData();
      }
      
      
      /**
       * Get data for the visualization
       * 
       * @return
       */
      function getData() {
          // ask for the data
          //var queryString = "http://demo.sensetecnic.com/SenseTecnic/api/sensors/mule1/data";
          var queryString = "http://demo.sensetecnic.com/SenseTecnic/api/sensors/" + android.sensorName() + "/data?wait=5000&beforeE=" + android.getBeforeE();
          var query = new google.visualization.Query(queryString);
          query.send(qResponseHandler);
      };
      
      
      /**
       * Handle response from DataTable servlet
       * 
       * @param response
       * @return
       */
      function qResponseHandler(response) {
          // internal error, means that the server side has a bug
          if (response.isError()) {
              // indicate error using vis
              google.visualization.errors.addError(document.getElementById('chart_div'),
            response.getMessage(), response.getDetailedMessage(), {'showInTooltip': false});
              return;
          }
          
        var data = response.getDataTable();
        // Create a formatter.
        // This example uses object literal notation to define the options.
        var formatter = new google.visualization.DateFormat({pattern: "h:mm:ss"});
		
         // Reformat our data.
        formatter.format(data, 1);
		
		//Remove Columns
		data.removeColumn(0);
		data.removeColumns(1,2);
          // draw the table with the data
        chart.draw(data,
        {
            width: 500, height: 200,
            legend: "none",
            vAxis: {minValue: 0},
            title: android.fullName()
        });
        
      };
--></script>
  </head>

  <body>
    <!--Div that will hold the pie chart-->
    <div id="chart_div"></div>
  </body>
</html>